﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using skags.Models;

namespace skags.Controllers
{
    [HandleError]
    [LogError]
    public class LinksController : Controller
    {
        /* GET: /Links/ - skilar öllum linkum */
        public ActionResult Index()
        {
            var rep = new LinksRepository();

            var allLinksAndCat = rep.GetAll();

            return View(allLinksAndCat);
        }

        /* GET: /Links/Category/5 - Skilar ákveðnum flokki */
        public ActionResult Category(int id)
        {
            var rep = new LinksRepository();
            var _dc = new DBDataContext();

            var allLinksAndCat = rep.GetLinksByCategoryID(id);
            ViewData["CategoryName"] = _dc.LinkCategories.Where(s => s.ID == id).SingleOrDefault().Title;

            return View(allLinksAndCat);
        }
    }
}